<div id="ad" class="tableform widgetconfig">
<{button label=$___b2c="添加图片广告"|t:'b2c' app="desktop" icon="btn_add.gif" id="add_ad_pic" onclick=""}>
<{button label=$___b2c="添加FLASH广告"|t:'b2c' app="desktop" icon="btn_add.gif" id="add_ad_flash" onclick=""}>
<{button label=$___b2c="自定义广告"|t:'b2c' app="desktop" icon="btn_add.gif" id="add_ad_html" onclick=""}>
<!--    <span class="sysiconBtn addorder" id="add_ad_pic" onclick="">添加图片广告</span>
    <span class="sysiconBtn addorder" id="add_ad_flash" onclick="">添加FLASH广告</span>
    <span class="sysiconBtn addorder" id="add_ad_html" onclick="">自定义广告</span>-->
    <div class="division"></div>
  <{foreach from=$setting.ad item=data key=key}>
  <div id="ad_<{$data.i}>">
    <input type=hidden name=ad[<{$data.i}>][type] value="<{$data.type}>">
    <input type=hidden name=ad[<{$data.i}>][i] value="<{$data.i}>">
    <{if $data.type=='image'}>
    <{t app="b2c"}>图片地址:<{/t}><input name=ad[<{$data.i}>][link] value="<{$data.link}>">
    <{t app="b2c"}>链接地址:<{/t}><input name=ad[<{$data.i}>][tolink] value="<{$data.tolink}>">
    <{elseif $data.type=='flash'}>
    <{t app="b2c"}>Flash地址:<{/t}><input name=ad[<{$data.i}>][link] value="<{$data.link}>">
    <{elseif $data.type=='html'}>
    <{t app="b2c"}>广告代码:<{/t}><textarea name=ad[<{$data.i}>][link]><{$data.link|escape:"html"}></textarea>
    <{/if}>
    <span onclick="delLink('ad_<{$data.i}>');">
	   <{img src="bundle/delecate.gif" style="cursor:pointer;" alt=$___b2c="删除"|t:'b2c' title=$___b2c="删除"|t:'b2c'}>
	</span>
  </div>
  <{/foreach}>
</div>
<script>
$('add_ad_pic').addEvent('click',function(){
  var d=new Date();
  var i=d.getTime();
  $E('#ad .division').setHTML($E('#ad .division').innerHTML+='\
    <div id="ad_'+i+'">\
       <table cellpadding="0" cellspacing="0">\
         <tr>\
            <th><{t app="b2c"}>图片地址:<{/t}></th>\
          <td><input name=ad['+i+'][link] size=15></td>\
           <th><{t app="b2c"}>链接地址:<{/t}></th>\
          <td><input name=ad['+i+'][tolink] size=15></td>\
          <td style="width:30px"><span onclick="delLink(\'ad_'+i+'\');"><{img src="bundle/delecate.gif" style="cursor:pointer;" alt=$___b2c="删除"|t:'b2c' title=$___b2c="删除"|t:'b2c'}></span></td>\
         </tr>\
       <table cellpadding="0" cellspacing="0">\
      <input type=hidden name=ad['+i+'][i] value="'+i+'">\
      <input type=hidden name=ad['+i+'][type] value="image">\
    </div>\
  ');
});

$('add_ad_flash').addEvent('click',function(){
  d=new Date();
  i=d.getTime();
  $E('#ad .division').setHTML($E('#ad .division').innerHTML+='\
    <div id="ad_'+i+'">\
        <table cellpadding="0" cellspacing="0">\
         <tr>\
            <th><{t app="b2c"}>Flash地址:<{/t}></th>\
          <td><input name=ad['+i+'][link]>\</td>\
          <td style="width:30px"><span onclick="delLink(\'ad_'+i+'\');"><{img src="bundle/delecate.gif" style="cursor:pointer;" alt=$___b2c="删除"|t:'b2c' title=$___b2c="删除"|t:'b2c'}></span></td>\
         </tr>\
       <table cellpadding="0" cellspacing="0">\
      <input type=hidden name=ad['+i+'][i] value="'+i+'">\
      <input type=hidden name=ad['+i+'][type] value="flash">\
    </div>\
  ');
});

$('add_ad_html').addEvent('click',function(){
  d=new Date();
  i=d.getTime();
  $E('#ad .division').setHTML($E('#ad .division').innerHTML+='\
    <div id="ad_'+i+'">\
      <table cellpadding="0" cellspacing="0">\
         <tr>\
            <th><{t app="b2c"}>广告代码:<{/t}></th>\
          <td><textarea name=ad['+i+'][link]></textarea></td>\
          <td style="width:30px"><span onclick="delLink(\'ad_'+i+'\');"><{img src="bundle/delecate.gif" style="cursor:pointer;" alt=$___b2c="删除"|t:'b2c' title=$___b2c="删除"|t:'b2c'}></span></td>\
         </tr>\
       <table cellpadding="0" cellspacing="0">\
      <input type=hidden name=ad['+i+'][i] value="'+i+'">\
      <input type=hidden name=ad['+i+'][type] value="html">\
    </div>\
  ');
});

delLink=function(o){
  $(o).remove();
}
</script>